package com.wehealth.adapter;

import java.util.ArrayList;
import java.util.List;

import com.wehealth.R;
import com.wehealth.dm.DM_Messages;
import com.wehealth.dm.DM_PlanDay;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class Adapter_message extends BaseAdapter{
	
	private List<DM_Messages> theList;
	private LayoutInflater mInflater;
	
	public Adapter_message(Context context,List<DM_Messages> theList){
		mInflater = LayoutInflater.from(context); 
		this.theList = theList;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return theList.size();
	}

	@Override
	public Object getItem(int pos) {
		// TODO Auto-generated method stub
		return pos;
	}

	@Override
	public long getItemId(int pos) {
		// TODO Auto-generated method stub
		return pos;
	}

	@Override
	public View getView(int pos, View arg1, ViewGroup view2) {
		// TODO Auto-generated method stub
		View view = mInflater.inflate(R.layout.message_adpater, null);
		TextView titleView = (TextView) view.findViewById(R.id.message_title);
		ImageView icon=(ImageView)view.findViewById(R.id.message_icon);
		final DM_Messages item =theList.get(pos);
		titleView.setText(item.getTitle());
		if(item.getState().equals("0")){
			icon.setImageResource(R.drawable.icon_message0);
		}else{
			icon.setImageResource(R.drawable.icon_message1);
		}
		return view;
	}

}
